/**
 * 快速排序
 */
Array.prototype.quick = function(){
    let _this = this;
    function potholing(leftPointer , rightPointer){
          if( rightPointer - leftPointer < 1) return
 
          let initialLeftPointer = leftPointer;
          let initialReftPointer =  rightPointer
          let cardinalNum = _this[leftPointer];
          let direction = -1 

          while(leftPointer != rightPointer){
            // 右指针移动
            if(direction == -1){
                if(_this[rightPointer] < cardinalNum){
                    _this[leftPointer] = _this[rightPointer];
                    direction = 1
                }else{
                    rightPointer--;
                }
            }
            // 左指针移动
            if(direction == 1){
                if(_this[leftPointer] > cardinalNum){
                    _this[rightPointer] = _this[leftPointer]
                    direction = -1
                }else{
                    leftPointer++
                }
            }
        }
        _this[leftPointer] = cardinalNum; 
 
        potholing(initialLeftPointer,leftPointer-1);
        potholing(leftPointer+1,  initialReftPointer);
    }
    potholing(0, _this.length-1);

}


let arr = [4,-1,5,-2,1500,-100,-1000,10000,-4,20];
arr.quick();
console.log(arr);